<?php
include 'config.php';
date_default_timezone_set('GMT +1');
$tm=date("Y.m.d H:i:s"); 
$ref=htmlspecialchars(mysql_real_escape_string($_SERVER["HTTP_REFERER"]));
$agent=$_SERVER["HTTP_USER_AGENT"];
$agent2=htmlspecialchars(mysql_real_escape_string($agent));
$ip=$_SERVER["REMOTE_ADDR"];
$ip2=mysql_real_escape_string($ip);
if(mysql_num_rows(mysql_query("SELECT ip FROM " . $tablename . " WHERE ip = '$ip'"))){
echo "already stored";
} else {
$strSQL = "INSERT INTO $tablename(tm, ref, agent, ip, tracking_page_name) VALUES ('$tm','$ref','$agent2','$ip','$tracking_page_name')";
$test=mysql_query($strSQL);
}
?>
